#include <stdio.h>
int main(){
    char *filename = "test2.txt";
    FILE *myfile = fopen(filename,"a+");
    if(myfile==NULL){
        printf("文件打开失败\r\n");
    }else{
        printf("文件打开成功\r\n");
    }
    //向文件中写入一个字符

    int result = fprintf(myfile,"警告：你的账户，余额仅剩%d元！",1);
    if(result==EOF){
        printf("向文件中写入字符串失败\r\n");
    }else{
        printf("向文件中写入字符串成功\r\n");
    }
    result = fclose(myfile);
    if(result!=0){
        printf("文件关闭失败%d\r\n",result);
    }else{
        printf("文件关闭成功%d\r\n",result);
    }
    return 0;
}